<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h1>注册表单</h1>
    <form action="/lession01/regist" method="post">
        <div class="item">
            <label for="">用户名</label>
            <input type="text" name="username">
        </div>
        <div class="item">
            <label for="">密码</label>
            <input type="password" name="password">
        </div>
        <div class="item">
            <label for="">性别</label>
            <input type="radio" name="sex" value="男">男
            <input type="radio" name="sex" value="女">女
            <input type="radio" name="sex" value="其它">其它
        </div>
        <div class="item">
            <label for="">出生日期</label>
            <input type="date" name="birthDay" >
        </div>
        <div class="submit">
            <input type="submit" value="提交">
        </div>
    </form>


    <script>
        let obj = { name: "张三", age: 13, sex: '男' };
        // 将这样一个对象转化成 name=张三&age=13&sex=男
        // 将这样一个对象转化成 {"name": "张三", "age": 13, "sex": "男"}
        console.log(JSON.stringify(obj));
        let res = "{"
        for(let i in obj){
            if(typeof obj[i] === "number"){
                res +=  `"${i}":${obj[i]},`
            }else{
                res +=  `"${i}":"${obj[i]}",`
            }
        }
        let json = res.slice(0,-1).concat("}")
        console.log(json);

        let xhl = new XMLHttpRequest()
        xhl.onreadystatechange = function(){
            console.log(xhl.readyState);
            if(xhl.readyState ===4){
                console.log(xhl.responseText);
            }
        }
        xhl.open("get","/lession01/getUserInfo",true)
        xhl.send()
    </script>
</body>

</html>